<template>
  <div class="product">
    <!--添加消息模板-->
    <div class="common-level-rail">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label-width="200px">
          <el-select v-model="stock_id" clearable filterable placeholder="選択してください">
            <el-option
              v-for="item in addressList"
              :key="item.id"
              :label="item.address"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button>検索</el-button>
        </el-form-item>
      </el-form>
    </div>

    <!--内容-->
    <div class="product-content">
      <div class="table-wrap">
        <el-table
          size="small"
          :data="tableData"
          border
          default-expand-all
          :tree-props="{ children: 'children' }"
          row-key="plus_id"
          v-loading="loading"
          empty-text="データがありません"
        >
          <el-table-column prop="address" label="保管場所"></el-table-column>
          <el-table-column prop="create_time" label="作成日"></el-table-column>
          <el-table-column fixed="right" label="操作">
            <template #default="scope">
              <el-button
                @click="editClick(scope.row)"
                link
                type="primary"
                size="small"
                >編集</el-button
              >
              <el-button
                @click="deleteClick(scope.row)"
                link
                type="primary"
                size="small"
                >削除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import stockcontrolApi from "@/api/stockcontrol.js";
import stockApi from "@/api/stock.js";
import { deepClone } from "@/utils/base.js";
export default {
  data() {
    return {
      loading: true,
      /*切换选中值*/
      activeIndex: "0",
      /*横向表单数据模型*/
      formInline: {
        stock_id: "",
      },
      /*表格数据*/
      tableData: [],
      /*总条数*/
      totalDataNumber: 0,
      /*分类列表*/
      categoryList: [],
      /*是否打开添加弹窗*/
      open_add: false,
      /*是否打开编辑弹窗*/
      open_edit: false,
      /*当前编辑的对象*/
      messageModel: {},
      /*是否打开字段弹窗*/
      open_field: false,
      addressList: [],
      stock_id: '',
    };
  },
  created() {
    /*获取列表*/
    this.getTableList();
    this.getAddres();
  },
  methods: {
    /*获取列表*/
    getTableList() {
      let self = this;
      let Params = {};
      stockcontrolApi
        .lists(Params, true)
        .then((data) => {
          self.loading = false;
          self.tableData = data.data.list;
          self.totalDataNumber = data.data.list.total;
        })
        .catch((error) => {
          self.loading = false;
        });
    },
    /*获取列表*/
    getAddres() {
      let self = this;
      let Params = {};
      stockApi
        .lists(Params, true)
        .then((data) => {
          self.loading = false;
          self.addressList = data.data.list;
        })
        .catch((error) => {
          self.loading = false;
        });
    },
  },
};
</script>

<style></style>
